﻿/// <reference path="//Microsoft.WinJS.1.0/js/base.js" />
WinJS.Namespace.define("Controls", {
    Repeater: WinJS.Class.define(function (itemTemplateId) {
        this.template = itemTemplateId;
    }, {
        render: function (objectsToRender, container) {
            var self = this;
            return new WinJS.Promise(function (complete) {
                if (!container) {
                    container = document.createElement("div");
                    container.setAttribute("id", "content");
                    document.body.appendChild(container);
                }

                for (var i = 0; i < objectsToRender.length; i++) {
                    var temp = document.getElementById(self.template).winControl;
                    temp.render(objectsToRender[i], container);
                }

                complete(container);
            });
        },

        _saveDescription: function (container) {
            var computers = container.getElementsByClassName("computer");

            for (var i = 0; i < computers.length; i++) {
                var ratingDiv = document.createElement("div");
                ratingDiv.setAttribute("class", "computer-rating");

                var ratingElement = new WinJS.UI.Rating(ratingDiv);

                computers[i].appendChild(ratingDiv);
            }
        }
    }, {})
});